package cn.sdhuijin.healthexam.activity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import cn.sdhuijin.healthexam.ExitApplication;
import cn.sdhuijin.healthexam.R;
import cn.sdhuijin.healthexam.control.AbstractControlActivity;
import cn.sdhuijin.healthexam.util.Constants;

/**
 * 产前第三次随访第一页
 * 
 * @author sunping
 * 
 */
public class ChanQianThirdVisitFirstActivity extends AbstractControlActivity
		implements OnClickListener {

	// 创建日期ID
	private String createDate;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_third_chanqian_visit_first);
		ExitApplication.getInstance().addActivity(this);

		Intent intent = getIntent();
		Bundle bundle = intent.getBundleExtra("bundle");
		if (bundle != null) {
			createDate = bundle.getString("createDate");
		}
		setCurrentEditUserName(createDate);

		addEditTextView(R.id.edt_name, "姓名");
		addEditTextView(R.id.edt_identify_num, "身份证号");
		addEditTextView(R.id.edt_yunzhou, "孕周");
		addEditTextView(R.id.edt_zhusu, "主诉");
		addEditTextView(R.id.edt_tizhong, "体重");
		addEditTextView(R.id.edt_gongdigaodu, "宫底高度");
		addEditTextView(R.id.edt_fuwei, "腹围");
		addEditTextView(R.id.edt_taiwei, "胎位");
		addEditTextView(R.id.edt_taixinlv, "胎心率");
		addEditTextView(R.id.edt_blood_pressure_gao, "高压");
		addEditTextView(R.id.edt_blood_pressure_di, "低压");

		// Properties文件路径
		controlManager.setPropertiesPath(Constants.PROPERTIES_PATH + createDate
				+ ".txt");
		Log.i(ChanQianThirdVisitFirstActivity.class.getSimpleName(), "文件路径： "
				+ Constants.PROPERTIES_PATH + createDate + ".txt");
		controlManager.toControl();

		setButtonListener(this, R.id.btn_next, R.id.btn_back);
	}

	/**
	 * 按钮点击处理事件
	 */
	@Override
	public void onClick(View arg0) {
		Intent intent = new Intent();
		Bundle bundle = new Bundle();
		// 获取点击按钮ID
		int id = (Integer) arg0.getId();
		switch (id) {
		case R.id.btn_next:
			controlManager.toProperties();
			// 下一步按钮
			intent.setClass(this, ChanQianThirdVisitSecondActivity.class);
			bundle.putString("createDate", createDate);
			intent.putExtra("bundle", bundle);
			startActivity(intent);
			this.finish();
			break;
		case R.id.btn_back:
			this.finish();
			break;
		default:
			break;
		}
	}
}
